var foo = (function () {
  let i = 0
  return function () {
    if (i) {
      return i;
    }
    i = Date()
    return i;
  }
})()
console.log(foo());
setTimeout(() => {
  console.log(foo());
}, 1000);